package com.meshnetics.gb.type.impl.zcl;

import com.meshnetics.gb.type.DataTypeID;

/**
 * WRITE DESCRIPTION HERE
 *
 * @author AKovylin
 */
public class TypeUInt extends FixedBytesDataType {
    private static final String ALIAS_PEFIX = "uint";
    private static final String ID_TYPE_CLASS = "Unsigned integer";
    private static final String ID_DATA_TYPE_PREFIX = "Unsigned ";
    private static final String ID_DATA_TYPE_POSTFIX = "-bit integer";

    public static final TypeUInt UINT_8 = new TypeUInt(1,
            new DataTypeID((byte) 0x20, ID_TYPE_CLASS, ID_DATA_TYPE_PREFIX + 8 + ID_DATA_TYPE_POSTFIX));
    public static final TypeUInt UINT_16 = new TypeUInt(2,
            new DataTypeID((byte) 0x21, ID_TYPE_CLASS, ID_DATA_TYPE_PREFIX + 16 + ID_DATA_TYPE_POSTFIX));
    public static final TypeUInt UINT_24 = new TypeUInt(3,
            new DataTypeID((byte) 0x22, ID_TYPE_CLASS, ID_DATA_TYPE_PREFIX + 24 + ID_DATA_TYPE_POSTFIX));
    public static final TypeUInt UINT_32 = new TypeUInt(4,
            new DataTypeID((byte) 0x23, ID_TYPE_CLASS, ID_DATA_TYPE_PREFIX + 32 + ID_DATA_TYPE_POSTFIX));
    public static final TypeUInt UINT_40 = new TypeUInt(5,
            new DataTypeID((byte) 0x24, ID_TYPE_CLASS, ID_DATA_TYPE_PREFIX + 40 + ID_DATA_TYPE_POSTFIX));
    public static final TypeUInt UINT_48 = new TypeUInt(6,
            new DataTypeID((byte) 0x25, ID_TYPE_CLASS, ID_DATA_TYPE_PREFIX + 48 + ID_DATA_TYPE_POSTFIX));
    public static final TypeUInt UINT_56 = new TypeUInt(7,
            new DataTypeID((byte) 0x26, ID_TYPE_CLASS, ID_DATA_TYPE_PREFIX + 56 + ID_DATA_TYPE_POSTFIX));
    public static final TypeUInt UINT_64 = new TypeUInt(8,
            new DataTypeID((byte) 0x27, ID_TYPE_CLASS, ID_DATA_TYPE_PREFIX + 64 + ID_DATA_TYPE_POSTFIX));

    protected TypeUInt(int byteSize, DataTypeID dataTypeId) {
        super(new String[]{ALIAS_PEFIX + byteSize * BITS_IN_BYTE}, dataTypeId, byteSize);
    }

    // no byte array cloning needed
    protected FixedBytesDataValue createValue(byte[] bytes) {
        return new UInt(this, bytes);
    }
}
